﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class FetchArticleClicked : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string id = Request.Params["aid"];
        if (id == null || id == "")
        {
            Response.Write("0");
        }
        else
        {
            TreasurerDataContext db = new TreasurerDataContext();
            var q = from aA in db.Articles
                    where aA.ID == id
                    select aA;
            if (q.Count() == 0)
            {
                Response.Write("0");
            }
            else
            {
                Articles a = q.First();
                a.Clicked++;

                db.SubmitChanges();

                Response.Write(a.Clicked);
            }
        }
    }
}